<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>组合继承</title>
</head>
<body>
<!-- 
    方式三： 原型链 + 借用构造函数 的组合继承
        1. 利用原型链实现对父类型对象的方法继承
        2. 利用super() 借用父类型构造初始化相同属性
 -->

<script type="text/javascript">
    function Person(name,age){
        this.name = name
        this.age = age
    }
    Person.prototype.setName = function(name){
        this.name = name
    }
    function Student(name,age,price){
        Person.call(this,name,age)  // 为了得到属性 ⭐📌
        /*  相当于 ⭐
            this.name = name
            this.age = age
        */
        this.price = price
    }
    Student.prototype = new Person() // 为了能看到父类型的方法⭐📌
    Student.prototype.constructor = Student // 修正constructor 属性
    Student.prototype.setPrice = function(price){
        this.price = price
    }

    var s = new Student('Tom',24,12000)
    s.setName('Nike')
    s.setPrice(14000)
    console.log(s.name,s.age,s.price)
</script>
</body>
</html>